import { handleActions } from 'redux-actions'
import { get_products_success } from '../actions/products'

const initalState = {
	// 根据销量
	sold: [],
	// 根据创建时间
	createdAt:[]
}

const productsReducer = handleActions({
	[get_products_success]: (state, action) => ({
		...state, // 当前initialState的所有数据
		[action.payload.sortBy]: action.payload.products
	})
},initalState)


export default productsReducer